/*
 * @Author: xmily
 * @Date: 2023-02-05 18:38:35
 * @LastEditors: xmily
 * @LastEditTime: 2023-02-05 23:45:16
 * @FilePath: \glxxapi\cfg\commMethod.js
 * @Description:
 *
 * Copyright (c) 2023 by xmily/mxthink.com.cn, All Rights Reserved.
 */
var siteBaseInfo = require("../models/sitebaseinfo.js");
var sitecfg=require("../cfg/siteconfig.js")

module.exports = {
  //获取学期列表
  getTermList: async function () {
    let temp = await siteBaseInfo.getTerm();
    return temp;
  },
  //获取学校所有班级名称
  getClassList:async function(term){
    // try {
      let query = [
        {
          $match: {
            schoolname: sitecfg.schoolname,
            term: term,
          },
        },
        {
          $unwind: "$classno",
        },
        {
          $sort: {
            sq: 1,
          },
        },
      ];
      let res = await siteBaseInfo.myAggregate(query, null, null);
      return res
      // ctx.body = {
      //   error: false,
      //   result: res,
      // };
    // } catch (err) {
    //   ctx.body = {
    //     error: true,
    //     message: err.message,
    //   };
    // }
  }
};
